package com.wanger.swa.config.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: wanger
 * @Date: 2024/10/7 1:17
 * @Description:
 */
@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<CustomFilter> customFilter() {
        FilterRegistrationBean<CustomFilter> registrationBean = new FilterRegistrationBean<>();

        registrationBean.setFilter(new CustomFilter());
        registrationBean.addUrlPatterns("/*"); // 过滤所有请求，可以根据需求修改
        registrationBean.setOrder(1); // 设置过滤器的优先级，数字越小优先级越高

        return registrationBean;
    }
}
